home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hráč 2004 August
/
Hrac_72_2004-08_dvd.iso
/
dema
/
Rapid Gun
/
rg_setup.exe
/
common
/
image_SaturationFilter.fx
< prev
next >
Wrap
Text File
|
2004-04-19
|
2KB
|
82 lines
// LF2 Engine
// (C) 2002-3 7FX
//---------------------------------------------------------------------------
// Desc
string desc : Description = "Image shader - color saturation.";
// Shader type phase
string type : Type = "image";
//---------------------------------------------------------------------------
// Render target texture
texture RT : RenderTargetFSMap;
//---------------------------------------------------------------------------
sampler sRT = sampler_state
{
Texture = <RT>;
MinFilter = POINT;
MagFilter = POINT;
AddressU = CLAMP;
AddressV = CLAMP;
};
//---------------------------------------------------------------------------
// Constants
const float4 cLum = {0.3f, 0.59f, 0.11f, 1.f};
const float4 c0 = {1.0, 1.0, 1.0, 1.0};
// Pixel shader
float4 PS(float2 uv: TEXCOORD0) : COLOR
{
float4 samp = tex2D(sRT, uv);
float4 r0 = samp;
r0.rgb = saturate(4 * (2 * (samp.rgb - 0.5f)));
float4 r1 = saturate(dot(r0.rgb, c0.rgb));
r1.rgb = dot(samp.rgb, cLum.rgb);
r0.rgb = lerp(r1.rgb, r0.rgb, r1.a);
return r0;
}
//---------------------------------------------------------------------------
technique vs0_ps20
{
pass p0
{
ZEnable = false;
ZWriteEnable = false;
PixelShader = compile ps_2_0 PS();
}
}
//---------------------------------------------------------------------------
technique vs0_ps11
{
pass p0
{
ZEnable = false;
ZWriteEnable = false;
Sampler[0] = <sRT>;
PixelShaderConstantF[0] = <c0>;
PixelShaderConstantF[1] = <cLum>;
PixelShader = asm
{
ps.1.1
tex t0
// saturate
mov_x4_sat r0.rgb, t0_bx2
dp3_sat r1.rgba, r0, c0
// grayscale
dp3 r1.rgb, t0, c1
// interpolate between color and grayscale
lrp r0.rgb, r1.a, r0, r1
// output alpha
+ mov r0.a, t0.a
};
}
}
//---------------------------------------------------------------------------